package com.mdn.gcalendar.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mdn.gcalendar.service.JsonReaderService;

@Controller
@RequestMapping("/feeds/calendarResource")
public class ResourceController {

	@Autowired
	JsonReaderService jsonReaderService;
	
	@RequestMapping(value="/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public @ResponseBody String getList() {
		return jsonReaderService.getTemplateContent("resource/get/list.json", null) ;
	}

	// TODO: habrá que ver si necesitamos parsear el json recibido en el request	
	@RequestMapping(value="/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public @ResponseBody String postEventCreate(HttpServletRequest request) {
		return jsonReaderService.getTemplateContent("resource/post/create.json", null);
	}
}
